package com.shallowdream.threaddemo.internetdownload;



public class DownUtilTest {

    public static void main(String args[]) throws Exception {
        final DownUtil downUtil = new DownUtil("https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.104/bin/apache-tomcat-7.0.104-windows-x64.zip", "D:\\64.zip", 3);

        downUtil.download();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                double completeRate = downUtil.getCompleteRate();
                while(completeRate<100.0){
                    if(completeRate==downUtil.getCompleteRate()){
                        continue;
                    }
                    System.out.println("已完成:"+downUtil.getCompleteRate()+"%");
                    completeRate=downUtil.getCompleteRate();

                      //  Thread.sleep(100);
                }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

}
